{if (($fans['status']==2 || ($theme['endtime']+432000) < TIMESTAMP) && $system['s']['isshare']==1) }
<script>
    {else}
    {php echo $config['iswxshare']==0?$register_jssdk:"<script src='https://res.wx.qq.com/open/js/jweixin-1.3.2.js'></script>";}

<script>

    var GLat;
    var GLng;
    var orderid  = 0;
    var orderno = '';
    var isflag = false;
    var shareData = {
        title: '{$sharetitle}',
        desc: '{$sharedesc}',
        imgUrl: '{$shareimgurl}',
        link: '{$shareurl}'
    };
    wx.ready(function () {



        {if $open_position==1}
        wx.getLocation({
            type: 'gcj02', //wgs84 或 gcj02
            success: function (res) {
                GLat = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                GLng = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                // $(".btns a").eq(0).attr('href',$(".btns a").eq(0).attr('href')+"uhubnunhbu");
                let user_location = "&user_location="+GLat+","+GLng;
                let new_user_location = GLat+","+GLng;
                for (let i=0;i<$(".btns a").length;i++){
                    let temp_href_val = $(".btns a").eq(i).attr('href');
                    if (temp_href_val.indexOf('javascript')<0){
                        $(".btns a").eq(i).attr('href',$(".btns a").eq(i).attr('href')+"&location="+user_location);
                    }
                }

                var postUrl = '/{php echo createMobileUrl("wx",array("themeid"=>$themeid,"from"=>"mobile","r"=>"education.index.GetShangJiaByLg"));}';
                $.ajax({
                    type:'POST',
                    dataType:'json',
                    data: {user_location:new_user_location},
                    url:postUrl,
                    success:function (res){
                        var data = res.data;
                        if (data){
                            $("#serviceList_ul").html(data.serviceList);

                            if(mySwiper&&mySwiper.destroy){
                                mySwiper.destroy();
                                mySwiper = new Swiper('.organization .list', {
                                    slidesPerView: 3.8
                                })
                            }else{
                                mySwiper = new Swiper('.organization .list', {
                                    slidesPerView: 3.8
                                })
                            }
                        }
                    }
                });
            },
            fail: function (res) {
                console.log(res);
                alert('定位失败：无法帮您排序商家！');
                // let user_location = "&user_location=";
                // for (let i=0;i<$(".btns a").length;i++){
                //     let temp_href_val = $(".btns a").eq(i).attr('href');
                //     if (temp_href_val.indexOf('showPoster')<0){
                //         $(".btns a").eq(i).attr('href',$(".btns a").eq(i).attr('href')+"&location="+user_location);
                //     }
                // }
            }
        });
        {/if}




        {if $canshare == 0}
        wx.hideOptionMenu();
        {else}
        wx.showOptionMenu();
        {/if}


            wx.onMenuShareAppMessage({
                title: shareData.title,
                desc: shareData.desc,
                link: shareData.link,
                imgUrl: shareData.imgUrl,
                trigger: function (res) {
                },
                success: function (res) {

                    setTimeout(function(){
                        dosharepyq(0);
                    }, 500);
                },
                cancel: function (res) {
                },
                fail: function (res) {
                }
            });

            wx.onMenuShareTimeline({
                title: shareData.title,
                link: shareData.link,
                imgUrl: shareData.imgUrl,
                success: function () {
                    setTimeout(function(){
                        dosharepyq(1);
                        {if $config['iscomm']==1 && $config['comm41'] > 0}
                        dosharehb();
                        {/if}
                            {if $config['iscomm']==1 && $system['fenxiao07'] > 0}
                            doyaoyiyaohb();
                            {/if}
                            }, 500);
                },
                cancel: function () {
                }
            });

        });

    wx.error(function (res) {
    });

    {/if}

        $(function(){
            $("#topay").click(function() {

                var status = $('#status').val();
                if(status == "0"){
                    alert('活动尚未开始哦');
                    return false;
                }
                if(status == "2"){
                    alert('活动已经结束啦');
                    return false;
                }
                {if (!empty($myworker) && $myworker['level']<=3 && empty($config['isworkerpay']))}

                alert('员工不可以报名,如需测试请用非员工微信');
                return false;
                {/if}

                    {if $isyixuan == true}

                    alert('客户活动进行中,不可测试');
                    return false;
                    {/if}

                        var address = $("#address").val();
                        {if $config['shopstype'] == 0 }
                        var option = $('#shops option:selected').val();
                        {else}
                        var option = $("#shops").val();
                        {/if}
                            var code = $('#code option:selected').val();
                            var datetime = $("#datetime").val();
                            var addinfo = $("#addinfo").val();
                            var xieyi = $("input[name='xieyi']:checkbox").attr('checked');
                            {if !empty($config['shops'])}
                            if(option.length <=0){
                                alert('请选择{$config['shops']}');
                                return false;
                            }
                            {/if}

                                var joinidv = 0;
                                var username = $('#nametext').val();
                                var mobile = $("#mobiletext").val();
                                if(username.length == 0){

                                    alert('请输入{$config['nametext']}');
                                    return false;
                                }
                                if(mobile.length != 11){

                                    alert('请输入格式正确的{$config['mobiletext']}');
                                    return false;
                                }

                                {if !empty($config['address'])}
                                if(address.length <=0){
                                    alert('请输入{$config['address']}');
                                    return false;
                                }
                                {/if}
                                    {if !empty($config['datetime'])}
                                    if(datetime.length <=0){
                                        alert('请输入{$config['datetime']}');
                                        return false;
                                    }
                                    {/if}
                                        {if !empty($config['addinfo'])}
                                        if(addinfo.length <=0){
                                            alert('请输入{$config['addinfo']}');
                                            return false;
                                        }
                                        {/if}

                                            // closeBox();
                                            if(isflag){
                                                isflag = true;
                                                return false;
                                            }
                                            joinidv = "{php echo $joinid;}";
                                            recordid = "{php echo $recordid;}";
                                            console.log(joinidv);
                                            tips("正在支付...");
                                            $.ajax({
                                                type:'POST',
                                                dataType : "json",
                                                data:{joinid:joinidv,recordid:recordid,username:username,mobile:mobile,address:address,option:option,code:code,datetime:datetime,addinfo:addinfo,course_address:confirm_course_address,
                                                    gift_ids:gift_ids},
                                                url:'/{php echo createMobileUrl("yxpay",array("op"=>"ready","themeid"=>$themeid,"recordid"=>$recordid,"workerid"=>$workerid,"fromuid"=>$fromuid,"fopenid"=>$fopenid));}',
                                                success:function(data){
                                                    var json = data.message;
                                                    console.log(json);
                                                    if(json.errcode == 0){
                                                        if(json.payway == 0){
                                                            window.location.href = json.url;
                                                        }else{
                                                            //tips(json.tid);
                                                            util.pay({
                                                                orderFee : json.fee,
                                                                payMethod : 'wechat',
                                                                orderTitle : json.title,
                                                                orderTid : json.tid,
                                                                module : '{$_P['m']}',
                                                                success : function(result) {
                                                                    {if empty($config['payedurl'])}
                                                                    tips2('支付成功',window.location.href);
                                                                    {else}
                                                                    tips2('支付成功','{$config["payedurl"]}');
                                                                    {/if}
                                                                    },
                                                                    fail : function(result) {
                                                                        alert('fail : ' + result.message);
                                                                    },
                                                                    complete : function(result) {
                                                                        location.reload();
                                                                    }
                                                                });
                                                        }
                                                    }else if(json.errcode == 110){
                                                        tips2(json.msg,json.url);
                                                    }else if(json.errcode == 111){
                                                        tips2(json.msg,window.location.href+'&username='+json.username+'&mobile='+json.mobile);
                                                    }else{
                                                        tips2(json.msg,'/{php echo createMobileUrl("index",array("themeid"=>$themeid));}');
                                                    }
                                                }
                                            });
                                        });
        })


        function checkorder(){
            if(orderno== ""){
                alert('定单号为空');return false;
            }
            $.ajax({
                type:'POST',
                dataType : "json",
                data:{orderid:orderid},
                url:'/{php echo createMobileUrl("yxpay",array("themeid"=>$themeid,"op"=>"check"));}',
                success:function(data){
                    var json = data.message;
                    if(json.errcode == 0){
                        tips2(json.msg,json.url);
                    }else{
                        checkorder();
                    }
                }
            });
        }
</script>